#include<cstdio>
int n,T,k,k1,k2,v,w,a[10005],b[10005],c[10005];
int xc(int x,int y,int p,int q){
	if(x>p)return 1;
	if(x<p)return 2;
	if(y>q)return 1;
	if(y<q)return 2;
	return 0;
}
void px(int x,int y){
	int r=x,l=y,mia=a[(r+l)/2],mib=b[(r+l)/2];
	while(r<=l){
		while(a[r]<mia)r++;
		while(xc(a[r],b[r],mia,mib)==2)r++;
		while(xc(a[l],b[l],mia,mib)==1)l--;
		if(r<=l){
			v=a[r];a[r]=a[l];a[l]=v;
			v=b[r];b[r]=b[l];b[l]=v;
			c[b[r]]=r;c[b[l]]=l;
			r++;l--;
		}
	}
	if(r<y)px(r,y);
	if(x<l)px(x,l);
	return;
}
int main(){
	freopen("sort.in","r",stdin);
	freopen("sort.out","w",stdout);
	scanf("%d %d",&n,&T);
	for(int i=1;i<=n;i++){scanf("%d",&a[i]);b[i]=c[i]=i;}
	px(1,n);
	while(T--){
		scanf("%d",&w);
		if(w==1){
			scanf("%d %d",&k1,&k2);
			k=c[k1];a[k]=k2;
			while(k>1&&xc(a[k-1],b[k-1],a[k],b[k])==1){
				v=a[k-1];a[k-1]=a[k];a[k]=v;
				v=b[k-1];b[k-1]=b[k];b[k]=v;
				c[b[k-1]]=k-1;c[b[k]]=k;
				k--;
			}
			while(k<n&&xc(a[k],b[k],a[k+1],b[k+1])==1){
				v=a[k];a[k]=a[k+1];a[k+1]=v;
				v=b[k];b[k]=b[k+1];b[k+1]=v;
				c[b[k+1]]=k+1;c[b[k]]=k;
				k++;
			}
		}
		if(w==2){
			scanf("%d",&k);
			printf("%d\n",c[k]);
		}
	}
}
